{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "00743dac-0e70-45b7-879a-d7293a6f68a6",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from dotenv import load_dotenv\n",
    "from scraper import fetch_website_contents\n",
    "from IPython.display import Markdown, display\n",
    "from openai import OpenAI\n",
    "\n",
    "# Load environment variables in a file called .env\n",
    "\n",
    "load_dotenv(override=True)\n",
    "api_key = os.getenv('OPENAI_API_KEY')\n",
    "\n",
    "# Check the key\n",
    "\n",
    "if not api_key:\n",
    "    print(\"No API key was found - please head over to the troubleshooting notebook in this folder to identify & fix!\")\n",
    "elif not api_key.startswith(\"sk-proj-\"):\n",
    "    print(\"An API key was found, but it doesn't start sk-proj-; please check you're using the right key - see troubleshooting notebook\")\n",
    "elif api_key.strip() != api_key:\n",
    "    print(\"An API key was found, but it looks like it might have space or tab characters at the start or end - please remove them - see troubleshooting notebook\")\n",
    "else:\n",
    "    print(\"API key found and looks good so far!\")\n",
    "\n",
    "\n",
    "#\n",
    "openai = OpenAI()\n",
    "\n",
    "# Step 1: Create your prompts\n",
    "\n",
    "system_prompt = \"\"\"\n",
    "You are an IBM Sterling Integrator software expert who has thoroughly read the all the latest documentation, technical support notes\n",
    "and knowledgebase. You also have experience deploying installations, creating complex business processes using BPML, and creating\n",
    "complex EDI and XML maps\"\"\"\n",
    "\n",
    "user_prompt = \"\"\"\n",
    "    Using BPML, please tell me how to create a business process that will translate a flat file to an X12 document using a map.\n",
    "    Please be specific with the names of services and adaptors you will use. Thanks.\n",
    "\"\"\"\n",
    "\n",
    "# Step 2: Make the messages list\n",
    "\n",
    "messages = [\n",
    "    {\"role\" : \"system\", \"content\" : system_prompt},\n",
    "    {\"role\" : \"user\", \"content\" : user_prompt}\n",
    "    ] # fill this in\n",
    "\n",
    "# Step 3: Call OpenAI\n",
    "# response =\n",
    "response = openai.chat.completions.create(\n",
    "        model = \"gpt-4.1-mini\",\n",
    "        messages = messages\n",
    "        )\n",
    "# Step 4: print the result\n",
    "# print(\n",
    "# print (response.choices[0].message.content)\n",
    "display(Markdown(response.choices[0].message.content))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
